{include file='_header'}
<script type="text/javascript" src="__STATIC__/js/lib/moment.js"></script>
<link rel="stylesheet" href="__STATIC__/components/datetimepicker/jquery.datetimepicker.css">
<link rel="stylesheet" href="__STATIC__/components/daterangepicker/daterangepicker.css">
<div class="page-header">
    当前位置：<span class="text-primary">{if !empty($item['id'])}编辑{else}添加{/if}商品 <small>{if !empty($item['id'])}修改【{$item['title']}】 {/if} </small></span>
</div>
<div class="page-content">
    <div class="page-sub-toolbar">
        <span class=''>
            <a class="btn btn-primary btn-sm" href="{:url('admin/auction/goodsadd')}">添加新商品</a>
        </span>
    </div>
<form id="dataform" action="" method="post" class="form-horizontal form-validate">
    <input type='hidden' id='gid' name='gid' value="{$item['gid']}" />
    <div class="form-group">
        <label class="col-lg control-label">商品标题</label>
        <div class="col-sm-9 col-xs-12">
            <input type="text" name="goods[title]" class="form-control" value="{$item['title']}" />
        </div>
    </div>
    <div class="form-group">
        <label class="col-lg control-label">拍卖时间</label>
        <div class="col-sm-4 col-xs-6">{:tpl_form_field_date('goods[starttime]', !empty($item['starttime']) ? date('Y-m-d H:i',$item['starttime']) : date('Y-m-d H:i'), 1)}</div>
        <div class="col-sm-4 col-xs-6">{:tpl_form_field_date('goods[endtime]', !empty($item['endtime']) ? date('Y-m-d H:i',$item['endtime']) : date('Y-m-d H:i'), 1)}</div>
    </div>
    <div class="form-group">
        <label class="col-lg control-label must">商品图片</label>
        <div class="col-sm-9 col-xs-12 gimgs">
            {:tpl_form_field_multi_image2('thumbs',$piclist)}
            <span class="help-block image-block" style="display: block;">第一张为缩略图，建议为正方型图片，其他为详情页面图片，尺寸建议宽度为640，并保持图片大小一致</span>
            <span class="help-block">您可以拖动图片改变其显示顺序 </span>
        </div>
    </div>
    <div class="form-group">
        <label class="col-lg control-label"><span style='color:red'>*</span>拍品分类</label>
        <div class="col-sm-8 col-xs-12">
            <select name="goods[category]" class="form-control">
            {foreach name='category' item='row'}
                <option value="{$row['id']}" {if $item['categoryid']==$row['id']}selected="selected"{/if}>{$row['name']}</option>
            {/foreach}}
            </select>
        </div>
    </div>
    <div class="form-group">
        <label class="col-lg control-label">起拍价格</label>
        <div class="col-sm-9 col-xs-12">
            <div class="input-group">
                <input type="text" name="goods[shprice]" class="form-control" value="{$item['shprice']}" {if !empty($item['starttime'])}{if time()>$item['starttime']}readonly="readonly"{/if}{/if}>
                <span class="input-group-addon">元</span>
            </div>
        </div>
    </div>
    <div class="form-group">
        <label class="col-lg control-label">加价幅度</label>
        <div class="col-sm-9 col-xs-12">
            <div class="input-group">
                <input type="text" name="goods[addprice]" class="form-control" value="{$item['addprice']}" {if !empty($item['starttime'])}{if time()>$item['starttime']}readonly="readonly"{/if}{/if}>
                <span class="input-group-addon">元</span>
            </div>
        </div>
    </div>
    <div class="form-group">
        <label class="col-lg control-label">保证金</label>
        <div class="col-sm-9 col-xs-12">
            <div class="input-group">
                <input type="text" name="goods[bond]" class="form-control" value="{$item['bond']}" {if !empty($item['starttime'])}{if time()>$item['starttime']}readonly="readonly"{/if}{/if}>
                <span class="input-group-addon">元</span>
            </div>
        </div>
    </div>
    <div class="form-group">
        <label class="col-lg control-label">商品详情</label>
        <div class="col-sm-9 col-xs-12">
            {:tpl_ueditor('goods[content]',$item['content'],array('height'=>200))}
        </div>
    </div>
    <div class="form-group">
        <label class="col-lg control-label">状态</label>
        <div class="col-sm-9 col-xs-12">
            <label class="radio radio-inline">
                <input type="radio" name="goods[status]" value="0" {if intval($item['status']) != 1}checked="checked"{/if}> 下架
            </label>
            <label class="radio radio-inline">
                <input type="radio" name="goods[status]" value="1" {if intval($item['status']) == 1}checked="checked"{/if}> 上架
            </label>
        </div>
    </div>
    {if !empty($id)}
    <div class="form-group">
        <label class="col-lg control-label">添加日期</label>
        <div class="col-sm-9 col-xs-12">
            <p class="form-control-static">{:date('Y-m-d', $item['createtime']);}</p>
        </div>
    </div>
    {/if}
    <div class="form-group">
        <label class="col-lg control-label"></label>
        <div class="col-sm-9 col-xs-12">
            <input type="submit"  value="保存商品" class="btn btn-primary" />
            <a class="btn btn-default " href="{:url('admin/auction/goods')}">返回列表</a>
        </div>
    </div>
</form>
</div>
<script type="text/javascript">
    $(function(){
        $('form').submit(function(){
            if($('input[name="goods[title]"]').val() == ''){
                $('form').attr('stop',1),tip.msgbox.err('请填写拍品名称.');
                return false;
            }
            if($('input[name="goods[thumb]"]').val() == ''){
                $('form').attr('stop',1),tip.msgbox.err('请上传拍品图片.');
                return false;
            }
            var addprice = parseFloat($('input[name="goods[addprice]"]').val());
            if(isNaN(addprice)){
                $('form').attr('stop',1),tip.msgbox.err('请填写拍品默认加价价格.');
                return false;
            }
            var shprice = parseFloat($('input[name="goods[shprice]"]').val());
            if(isNaN(shprice)){
                $('form').attr('stop',1),tip.msgbox.err('请填写商品起拍价格.');
                return false;
            }
            return true;
        });
    });
</script>
{include file='_footer'}